package com.ita.homework.two;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Hello world!
 * 
 */
public class CharactersFilter {

	public static final String DIGIT_REGEX = "\\d";
	public static final String ALPHABET_REGEX = "[a-zA-Z]";
	public static final String CHINESE_REGEX = "[\u4e00-\u9fa5]";
	public static final String PUNCTUATION_REGEX = "[\\pP\\pS\\pZ]";

	public int filter(String regex, String target) {

		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(target);
		int length = 0;
		while (matcher.find()) {
			length++;
			System.out.print(matcher.group());
		}
		System.out.println(" -->" + length + " characters");
		return length;

	}


}
